Starred
Allow users to like, save, or prioritize an item, often pinning it for quick access.
Examples
Use default starred variant for users to toggle the starred state of an item, and enable starring on most lists to allow customisation.
Composition:
- Icon only button: the primary interactive element.
- Star Icon: The primary visual element.
- Tooltip (Recommended): A brief text label appearing on hover or focus (e.g., "Marked as favorite").
Interaction:
- Default (Unstarred): An outlined star icon is used to show the item is not starred.
- Hover: A blue round square border and shadow displayed to indicate that is clickable.
- Starred: Typically, a filled star icon is used to indicate the item is starred.
- Disabled: The icon appears in a visually muted state (e.g., grayed out) with no interaction.
const [starred, setStarred] = useState(false);
return (
<Starred
isStarred={starred}
onChange={setStarred}
aria-label="Pin/unpin whatever this item is"
/>
);Disable the starred button when the user cannot star an item (e.g., due to permissions) or in read-only views.
const [starred, setStarred] = useState(false);
return (
<Starred
isStarred={starred}
onChange={setStarred}
aria-label="Pin/unpin whatever this item is"
disabled
/>
);Properties
| Property | Description | Defined | Value |
|---|---|---|---|
isStarredRequired | booleanIf true, the element selected is starred | ||
onChangeRequired | functionExecutes once starred button has changed | ||
aria-labelOptional | stringDescribe what happens if the button is clicked | ||
disabledOptional | booleanCan the button be clicked | ||
data-observe-keyOptional | stringUnique string, used by external script e.g. for event tracking | ||
classNameOptional | stringCustom className that's applied to the outermost element (only intended for special cases) | ||
styleOptional | objectStyle object to apply custom inline styles (only intended for special cases) | ||
tabIndexOptional | numberTab index of the outermost HTML element of the component | ||
onKeyDownOptional | functionCallback for onKeyDown event | ||
onMouseDownOptional | functionCallback for onMouseDown event | ||
onMouseEnterOptional | functionCallback for onMouseEnter event | ||
onMouseLeaveOptional | functionCallback for onMouseLeave event | ||
onFocusOptional | functionCallback for onFocus event | ||
onBlurOptional | functionCallback for onBlur event |
Guidelines
Best practices
Do not use when
Accessibility
Explore detailed guidelines for this component: Accessibility Specifications